/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.curso.service;

import com.curso.dao.serializables.UserDaoSer;
import com.curso.model.User;
import java.util.List;
import com.curso.exception.UserExistsException;
import com.curso.util.Constants;

/**
 *
 * @author Administrador
 */
public class UserService extends GenericService<User, Long> {

      /**
     * {@inheritDoc}
     */
    public User getUser(String userId) {
        return this.get(new Long(userId));
    }

    /**
     * {@inheritDoc}
     */
    public List<User> getUsers() {
        return this.getAll();
    }

    /**
     * {@inheritDoc}
     */
    public User saveUser(User user) throws UserExistsException {

        if (user.getVersion() == null) {
            // if new user, lowercase userId
            user.setUsername(user.getUsername().toLowerCase());
        }

        return this.save(user);
        
    }

 

    /**
     * {@inheritDoc}
     *
     * @param username the login name of the human
     * @return User the populated user object
     * @throws UsernameNotFoundException thrown when username not found
     */
    public User getUserByUsername(String username)  {
        return null; 
    }

    @Override
    public List<User> getAll() {
       return new UserDaoSer().getAll();
    }

    @Override
    public User get(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean exists(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public User save(User user) {
        return new UserDaoSer().save(user);
    }

    @Override
    public void remove(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Boolean removeUser(User u) {

        return new UserDaoSer().remove(u);
    }
}